<template>
  <view class="popWrap">
    <view class="topWrap">
      <view class="productDetail">
        <view style="width: 200rpx; height: 200rpx;">
          <u-image height="200" width="200" :src="detail.goodsPic" :lazy-load="true" mode="aspectFit"></u-image>
        </view>
        <view class="productDetailRight">
          <view>
            <up-text type="main" size="42" color="#000" :text="detail?.name || ''"></up-text>
          </view>
          <view class="price">
            <view class="unit">￥</view>
            <view class="categoryPrice">{{ detail?.price }}</view>
          </view>
        </view>
      </view>
      <view class="numberWrap">
        <up-text size="28" text="数量"></up-text>
        <u-number-box :value="number" :min="1" integer :buttonSize="60" inputWidth="70" @change="valChange"></u-number-box>
      </view>
    </view>
    <view class="bottomWrap">
      <view class="bottomBtnItem" style="background-color: #FDB51F;" @click="addShoppingCar">加入购物车</view>
      <view class="bottomBtnItem" style="background-color: #79C435;" @click="buyProduct">立即购买</view>
    </view>
  </view>
</template>

<script>

export default {
  props: {
    number: {
      type: Number,
      default: () => 1,
    },
    detail: {
      type: Object,
      default: () => {},
    }
  },
  data() {
    return {
    }
  },
  methods: {
    valChange(e) {
      this.$emit('valChange', e);
    },
    addShoppingCar() {
      this.$emit('addShoppingCar');
    },
    buyProduct() {
      this.$emit('buyProduct');
    },
  },
}
</script>

<style lang="scss" scoped>
.popWrap{
  height: 45vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
}
.topWrap {
  flex: 1;
  padding: 30rpx 30rpx 48rpx;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.bottomWrap {
  height: 108rpx;
  width: 100%;
  display: flex;
  flex-direction: row;
}
.bottomBtnItem {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 40rpx;
}
.numberWrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}
.productDetail {
  display: flex;
  flex-direction: row;
}
.productDetailRight {
  display: flex;
  flex-direction: column;
  margin-left: 24rpx;
  width: calc(100% - 290rpx);
}
.price {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: baseline;
  padding-bottom: 10rpx;
  margin-top: 48rpx;
}
.unit {
  color: #59B235;
  font-size: 28rpx;
}
.categoryPrice {
  color: #59B235;
  font-size: 42rpx;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  font-weight: 600;
}
</style>